package com.jeespring.elasticsearch.dto;

import java.io.Serializable;

/**
 * @description ResponseDTO
 * @author 张朝阳
 * @date 2019/5/8 22:55
 */
public class ResponseDTO<T> implements Serializable {

    private boolean success = true;

    private String message;

    private int code ;

    private T data;

    public ResponseDTO() {
    }

    public ResponseDTO(boolean success, String message) {
        super();
        this.success=success;
        this.message = message;
    }

    public ResponseDTO(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public ResponseDTO(T data) {
        this.setCode(200);
        this.data = data;
    }

    public static ResponseDTO success(){
        return new ResponseDTO(200);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResponseDTO(boolean success, T data) {
        this.success = success;
        this.data = data;
    }
}
